

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Python Examples &mdash; geoslurp Wannabe v1.0 documentation</title>
  

  
  
    <link rel="shortcut icon" href="_static/favicon.ico"/>
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script type="text/javascript" src="_static/jquery.js"></script>
        <script type="text/javascript" src="_static/underscore.js"></script>
        <script type="text/javascript" src="_static/doctools.js"></script>
        <script type="text/javascript" src="_static/language_data.js"></script>
        <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Establish a database connection and retrieve the inventory and User settings" href="examples/connectnQuery.html" />
    <link rel="prev" title="Using the command line tool geoslurp" href="usingcli.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> geoslurp
          

          
          </a>

          
            
            
              <div class="version">
                1.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">An introduction to Geoslurp</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation of the geoslurp package and setting up the PostgreSQL instance</a></li>
<li class="toctree-l1"><a class="reference internal" href="confsettings.html">Configuration</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="examples.html">Tutorial</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="usingcli.html">Using the command line tool geoslurp</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Python Examples</a><ul>
<li class="toctree-l3"><a class="reference internal" href="examples/connectnQuery.html">Establish a database connection and retrieve the inventory and User settings</a></li>
<li class="toctree-l3"><a class="reference internal" href="examples/UsingCataloguedDsets.html">Downloading and registering “catalogue” datasets</a></li>
<li class="toctree-l3"><a class="reference internal" href="examples/CreateDynDSet.html">Download and register a dynamic dataset of (crowd-sourced?) US Marijuana street prices</a></li>
<li class="toctree-l3"><a class="reference internal" href="examples/BasicDiscovery.html">Discovery techniques</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="reference.html">Reference Documentation</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">geoslurp</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
          <li><a href="examples.html">Tutorial</a> &raquo;</li>
        
      <li>Python Examples</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/pyexamples.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  
<style>
/* CSS overrides for sphinx_rtd_theme */

/* 24px margin */
.nbinput.nblast.container,
.nboutput.nblast.container {
    margin-bottom: 19px;  /* padding has already 5px */
}

/* ... except between code cells! */
.nblast.container + .nbinput.container {
    margin-top: -19px;
}

.admonition > p:before {
    margin-right: 4px;  /* make room for the exclamation icon */
}

/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */
.math {
    text-align: unset;
}
</style>
<div class="section" id="python-examples">
<h1>Python Examples<a class="headerlink" href="#python-examples" title="Permalink to this headline">¶</a></h1>
<p>All operations which are supported by the command line tool can also be performed in a more modular sense from python. In fact, actions can be defined more broadly when using the python interface. The use of the commandline interface is therefore not strictly necessary. The following sections show python examples which illustrate this. The Jupyter notebooks, which are used to build these examples can be downloaded from <a class="reference external" href="https://github.com/strawpants/geoslurp/tree/master/examples">the github repository</a>.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="examples/connectnQuery.html">Establish a database connection and retrieve the inventory and User settings</a><ul>
<li class="toctree-l2"><a class="reference internal" href="examples/connectnQuery.html#Read-only-user-versus-priviliged-user">Read-only user versus priviliged user</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/connectnQuery.html#Using-geoslurpConnect">Using geoslurpConnect</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/connectnQuery.html#Alternatively-one-can-use-the-class-GeoslurpConnector-and-provide-all-connections-details-manually">Alternatively one can use the class GeoslurpConnector and provide all connections details manually</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/connectnQuery.html#Loading-the-Dataset-Inventory">Loading the Dataset Inventory</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples/connectnQuery.html#Setting-and-getting-usersettings-from-the-database">Setting and getting usersettings from the database</a><ul>
<li class="toctree-l3"><a class="reference internal" href="examples/connectnQuery.html#Default-settings">Default settings</a></li>
<li class="toctree-l3"><a class="reference internal" href="examples/connectnQuery.html#Storing-and-retrieving-Authentication-details">Storing and retrieving Authentication details</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples/UsingCataloguedDsets.html">Downloading and registering “catalogue” datasets</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/CreateDynDSet.html">Download and register a dynamic dataset of (crowd-sourced?) US Marijuana street prices</a><ul>
<li class="toctree-l2"><a class="reference internal" href="examples/CreateDynDSet.html#Example:-US-street-prices-of-Marijuana">Example: US street prices of Marijuana</a><ul>
<li class="toctree-l3"><a class="reference internal" href="examples/CreateDynDSet.html#Create-the-stucture-of-the-database-table-using-sqalchemy-ORM-methods">Create the stucture of the database table using sqalchemy ORM methods</a></li>
<li class="toctree-l3"><a class="reference internal" href="examples/CreateDynDSet.html#Create-a-helper-function-to-extract-relevant-information-from-the-file">Create a helper function to extract relevant information from the file</a></li>
<li class="toctree-l3"><a class="reference internal" href="examples/CreateDynDSet.html#Inherit-from-DataSet">Inherit from DataSet</a></li>
<li class="toctree-l3"><a class="reference internal" href="examples/CreateDynDSet.html#Create-an-instance-of-the-class-and-call-the-pull,-and-register-methods-to-download-and-register-the-data">Create an instance of the class and call the pull, and register methods to download and register the data</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="examples/CreateDynDSet.html#Avoid-reinventing-the-wheel">Avoid reinventing the wheel</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples/BasicDiscovery.html">Discovery techniques</a><ul>
<li class="toctree-l2"><a class="reference internal" href="examples/BasicDiscovery.html#Query-a-single-table-and-visualize-the-result">Query a single table and visualize the result</a><ul>
<li class="toctree-l3"><a class="reference internal" href="examples/BasicDiscovery.html#Pick-a-state-and-plot-the-results-using-matplotlib">Pick a state and plot the results using matplotlib</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="examples/BasicDiscovery.html#A-more-complicated-query-which-joins-data-between-tables">A more complicated query which joins data between tables</a><ul>
<li class="toctree-l3"><a class="reference internal" href="examples/BasicDiscovery.html#Visualize-the-result-geographically-using-matplotlib">Visualize the result geographically using matplotlib</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="examples/connectnQuery.html" class="btn btn-neutral float-right" title="Establish a database connection and retrieve the inventory and User settings" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="usingcli.html" class="btn btn-neutral float-left" title="Using the command line tool geoslurp" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2020, Roelof Rietbroek

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>